/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vista;

import java.awt.event.KeyEvent;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JTextField;

/**
 *
 * @author Aguero
 */
public class Validaciones {


    public Validaciones() {
    }

    public static void ValidarSoloTexto(KeyEvent evt) {
        Character caracter = new Character(evt.getKeyChar());
        if (!(Character.isLetter(caracter) || caracter == ' ' )) {
            evt.consume();
        }
    }

     public static void ValidarCampoSoloNumerico(KeyEvent evt){
        char caracter = evt.getKeyChar();
        if((caracter < '0') || (caracter > '9')){
            evt.consume();
        }
    }

    public static void ValidarCampoVacio(KeyEvent evt){
        Character caracter = new Character(evt.getKeyChar());
        JTextField campo =(JTextField)evt.getSource();
        if (caracter == ' '&& campo.getText().length()==0){
            evt.consume();
        }
    }

    public static void LimitarCampo(KeyEvent evt, int tamanioLimitar) {
        JTextField campo = (JTextField) evt.getSource();
        if (campo.getText().length() >= tamanioLimitar) {
            evt.consume();
        }
    }

    public static void ValidarFilaNoSeleccionada(javax.swing.JDialog ventana){
        javax.swing.JOptionPane.showMessageDialog(ventana, "Seleccione un elemento de la lista", "Error", javax.swing.JOptionPane.INFORMATION_MESSAGE);
    }

    public static void ValidarProveedorYaExiste(javax.swing.JDialog ventana){
        javax.swing.JOptionPane.showMessageDialog(ventana, "Ya posee este proveedor", "Error", javax.swing.JOptionPane.INFORMATION_MESSAGE);
    }

    public static void ValidarFormularioVacio(javax.swing.JDialog ventana){
        javax.swing.JOptionPane.showMessageDialog(ventana, "No pueden haber campos vacíos", "Error", javax.swing.JOptionPane.INFORMATION_MESSAGE);
    }

    public static void ValidarStockNegativo(javax.swing.JDialog ventana){
        javax.swing.JOptionPane.showMessageDialog(ventana, "Stock negativo", "Error", javax.swing.JOptionPane.INFORMATION_MESSAGE);
    }

   
}
